const mysql = require('../../mysql')

async function getInfo(ctx){
  const info = await mysql('information')
  
  ctx.state = {
    data: info[0]
  }
} 

async function setInfo(ctx){
  const info = ctx.request.body
  try {
    await mysql('information').where('id', 1).update(info)
    ctx.state.data = {
      msg: '修改成功',
      state: true
    }
  } catch (err) {
    ctx.state = {
      code: -1,
      data: {
        msg: '修改失败',
        err
      }
    }
  }
}

module.exports = {
  getInfo,
  setInfo
}

